<?php
/**
 * Buildings Model for RoomBooking Component
 * 
 * @version    1.0
 * @package    Joomla
 * @subpackage RoomBooking
 * @copyright (C) 2011 Giovanni Marzulli
 * @license	   GNU/GPL
 */
 
// No direct access
defined('_JEXEC') or die();
 
jimport( 'joomla.application.component.model' );
 
class RoomBookingModelTypes extends JModel
{
    /**
     * Buildings data array
     *
     * @var array
     */
    var $_data;
 
    /**
     * Returns the query
     * @return string The query to be used to retrieve the rows from the database
     */
    function _buildQuery()
    {
        $query = ' SELECT * FROM #__roombooking_rooms_types ORDER BY id';
        return $query;
    }
 
    /**
     * Retrieves the buildings data
     * @return array Array of objects containing the data from the database
     */
    function getData()
    {
        // Lets load the data if it doesn't already exist
        if (empty( $this->_data ))
        {
            $query = $this->_buildQuery();
            $this->_data = $this->_getList( $query );
        }
 
        return $this->_data;
    }
    
	/**
    * Gets the buildings of Organization
    * @return object with data
    */
//    function getBuildings($id_organization)
//    {
//		$db =& JFactory::getDBO();
// 
//  		$query = 'SELECT id, name, address, date_format( opening, "%H:%i" ) as opening, date_format( closing, "%H:%i" ) as closing, we_opening'.
//  				 ' FROM #__roombooking_buildings AS r INNER JOIN '.
//  				 ' #__roombooking_building_organization  AS ro ON r.id=ro.id_building WHERE id_organization='.$id_organization;
//   		$buildings = $this->_getList( $query );
//   		
//   		return $buildings;
//    	
//    }
}
